package com.wugz.filter;

import com.alibaba.dubbo.rpc.*;

/**
 * @ClassName ProviderTransportIPFilter
 * @Description 服务提供者拦截器 获取ip 打印出来
 * @Author wugz
 * @Date 2020/5/9 14:50
 * @Version 1.0
 */
public class ProviderTransportIPFilter implements Filter {

    @Override
    public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
        String client_ip = RpcContext.getContext().getAttachment("client_ip");
        if(client_ip != null){
            System.out.println("service filter 接收到来自： " + client_ip + " 的请求");
        }
        return invoker.invoke(invocation);
    }
}
